how to calculate length of string in java